package com.mynewspaper.directaction;

import com.mynewspaper.app.DirectAction;
import com.mynewspaper.components.Main;
import com.webobjects.appserver.WOActionResults;
import com.webobjects.appserver.WOComponent;
import com.webobjects.appserver.WORequest;

public class DirectActionLogin extends DirectAction {

	public DirectActionLogin(WORequest request) {
		super(request);
	}
	
	public WOActionResults userAction() {
		//Session session = (Session)this.session();
		WOComponent page = pageWithName(Main.class.getName());
        String login = (String)this.request().formValueForKey("login");
        String password = (String)this.request().formValueForKey("pass");
        Boolean isLogin = session().login(login, password);
        page.takeValueForKey(!isLogin, "loginError");
		return page;
	}
	
	public WOActionResults logOutAction(){
		session().logOut();
		WOComponent page = pageWithName(Main.class.getName());
		return page;
	}
}
